#include "CommonConstant.h"

// temporary character buffer to store strings
char CommonConstant::buffer[255];
char CommonConstant::month[10];
char CommonConstant::day[10];
char CommonConstant::year[5];
char CommonConstant::stringPriority[8];

// common constant used in codes
const char CommonConstant::END_LINE = '\n';
const char CommonConstant::NULL_CHARACTER = '\0';
const char CommonConstant::WHITE_SPACE = ' ';
const char CommonConstant::COMMAND_SYMBOL = '/';
const int CommonConstant::TRUE = 1;
const int CommonConstant::FALSE = 0;
const int CommonConstant::INCREMENT = 1;
const int CommonConstant::DECREMENT = -1;
const int CommonConstant::DEFAULT_VALUE = 0;
const int CommonConstant::DEFAULT_TIME_SECONDS = 0;
const int CommonConstant::DEFAULT_TIME_MINUTES = 0;
const int CommonConstant::DEFAULT_TIME_HOURS = 0;
const int CommonConstant::DEFAULT_END_TIME_SECONDS = 59;
const int CommonConstant::DEFAULT_END_TIME_MINUTES = 59;
const int CommonConstant::DEFAULT_END_TIME_HOURS = 23;
const int CommonConstant::BASE_YEAR = 1900;
const int CommonConstant::INDEX_ZERO = 0;
const int CommonConstant::MAX_SIZE_24_TIME_STRING_FORMAT = 4;
const int CommonConstant::MAX_SIZE_24_TIME_STRING_COMMAND_FORMAT_SEARCH = 9;
const int CommonConstant::MAX_SIZE_TIME_STRING_FORMAT = 5;
const int CommonConstant::SIZE_DATE_STRING_FORMAT = 10;
const int CommonConstant::MAX_SIZE_DATE_STRING_FORMAT = 11;
const int CommonConstant::MAX_SIZE_MONTH_STRING_FORMAT = 10;
const int CommonConstant::MAX_SIZE_DAY_STRING_FORMAT = 10;
const int CommonConstant::MAX_SIZE_YEAR_STRING_FORMAT = 5;
const int CommonConstant::TM_MONTH_REFERENCE = 1;
const int CommonConstant::TM_YEAR_REFERENCE = 1900;
const int CommonConstant::TM_SUMMER_TIME_OFF = -1;
const int CommonConstant::TM_INITIALIZATION = 0;
const int CommonConstant::HISTORY_EMPTY_SIZE = 0;
const int CommonConstant::MONTH_STRING_MAX_LENGTH = 11;
const int CommonConstant::AMORPM_STRING_MAX_LENGTH = 3;
const int CommonConstant::MAX_LENGTH_TIME_FORMAT_1 = 4;
const int CommonConstant::MAX_LENGTH_TIME_FORMAT_2 = 7;
const int CommonConstant::STOI_BASE = 10;
const time_t CommonConstant::INFINITE_TIME = 999999999999;
const string CommonConstant::EMPTY_STRING = "";
const string CommonConstant::FULL_DATE_INFO = "%s, %s %s %s";
const string CommonConstant::TIME_24H_STRING_FORMAT = "%H%M";
const string CommonConstant::DATE_STRING_FORMAT = "%d/%m/%Y";
const string CommonConstant::DAY_STRING_FORMAT = "%A";
const string CommonConstant::MONTH_STRING_FORMAT = "%B";
const string CommonConstant::YEAR_STRING_FORMAT = "%Y";

// strings command
const string CommonConstant::COMMAND_CREATE = "create";
const string CommonConstant::COMMAND_DISPLAY = "display";
const string CommonConstant::COMMAND_UPDATE = "update";
const string CommonConstant::COMMAND_DELETE = "delete";
const string CommonConstant::COMMAND_SEARCH = "search";
const string CommonConstant::COMMAND_UNDO = "undo";
const string CommonConstant::COMMAND_REDO = "redo";
const string CommonConstant::COMMAND_EXIT = "exit";

// string message displayed to the user
const string CommonConstant::MESSAGE_CREATED  = "task successfully added/created";
const string CommonConstant::MESSAGE_DELETED = "task %d has been deleted";
const string CommonConstant::MESSAGE_INVALID_INDEX = "error: invalid index entered";
const string CommonConstant::MESSAGE_VALID_INDEX_FORMAT = "please enter 0-%d only"; 
const string CommonConstant::MESSAGE_NO_TASK = "there is no task in Taskline";
const string CommonConstant::MESSAGE_UPDATED = "task successfully updated";
const string CommonConstant::MESSAGE_INSERTED = "task inserted successfully";
const string CommonConstant::MESSAGE_EMPTY_FILE = "empty file";
const string CommonConstant::MESSAGE_EXIT = "See You Again";
const string CommonConstant::MESSAGE_INVALID_COMMAND = "invalid command format: %s";
const string CommonConstant::MESSAGE_UNSUCCESSFUL_FILE_UPDATE = "unsuccessful update";
const string CommonConstant::MESSAGE_WORD_NOT_FOUND = "word not found";
const string CommonConstant::MESSAGE_NO_USER_INPUT_AFTER_COMMAND = "no user input after delete command";
const string CommonConstant::MESSAGE_NO_USER_INPUT_AFTER_COMMAND_UPDATE = "no user input after update command";
const string CommonConstant::MESSAGE_INTEGER_VALUES_ONLY = "error: enter integer value only after delete command";
const string CommonConstant::MESSAGE_INVALID_FORMAT = "invalid format entered";
const string CommonConstant::MESSAGE_INDEX_OUT_OF_RANGE = "error: index specified is out of range.";
const string CommonConstant::MESSAGE_DELETE_UNDO_SUCCESSFULLY = "Undo successfully: Deleted task has been added back.";
const string CommonConstant::MESSAGE_UPDATE_UNDO_SUCCESSFULLY = "Undo successfully: Updated task has be restored with original value.";
const string CommonConstant::WELCOME_MESSAGE_LOADED_EXISTING_FILE = "Welcome to TaskLine.\nloaded existing file";
const string CommonConstant::WELCOME_MESSAGE_NEW_FILE = "Welcome to TaskLine.\ncreate a new file";
const string CommonConstant::WELCOME_MESSAGE_FILE_ERROR = "cannot open a file";
const string CommonConstant::MESSAGE_INVALID_TIME_FORMAT = "invalid time/date format: HHMM for time, DD/MM/YYYY for year";
const string CommonConstant::MESSAGE_INVALID_PRIORITY_FORMAT = "invalid priority format: 0 for HIGH, 1 for MEDIUM, 2 for LOW";
const string CommonConstant::MESSAGE_INVALID_STATUS_FORMAT = "invalid status format: 0 for UNFINISHED, 1 for FINISHED";
const string CommonConstant::MESSAGE_INVALID_START_TIME = "invalid start time: cannot be later than end time";
const string CommonConstant::MESSAGE_INVALID_END_TIME = "invalid end time: cannot be earlier than start time";
const string CommonConstant::MESSAGE_NO_REDOABLE_TASK = "No redoable task.";
const string CommonConstant::MESSAGE_NO_UNDOABLE_TASK = "No undoable task.";

// const attributes for task attributes
const char CommonConstant::TASK_TYPE_FLOATING = 'f';
const char CommonConstant::TASK_TYPE_DEADLINE = 'd';
const char CommonConstant::TASK_TYPE_TIMED = 't';
const char CommonConstant::TASK_TYPE_INVALID = 'X';
const int CommonConstant::TASK_INT_PRIORITY_HIGH = 0;
const int CommonConstant::TASK_INT_PRIORITY_MEDIUM = 1;
const int CommonConstant::TASK_INT_PRIORITY_LOW = 2;
const int CommonConstant::TASK_INT_STATUS_NOT_FINISHED = 0;
const int CommonConstant::TASK_INT_STATUS_FINISHED = 1;
const int CommonConstant::TASK_INT_INVALID = -1;
const int CommonConstant::DISPLAY_PRIORITY_SIZE = 8;
const string CommonConstant::TASK_ATTRIBUTE_INVALID = "INVALID";
const string CommonConstant::TASK_TITLE_UNTITLED = "no title";
const string CommonConstant::TASK_STRING_PRIORITY_HIGH = "HIGH";
const string CommonConstant::TASK_STRING_PRIORITY_MEDIUM = "MEDIUM";
const string CommonConstant::TASK_STRING_PRIORITY_LOW = "LOW";
const string CommonConstant::TASK_STRING_NUM_PRIORITY_HIGH = "0";
const string CommonConstant::TASK_STRING_NUM_PRIORITY_MEDIUM = "1";
const string CommonConstant::TASK_STRING_NUM_PRIORITY_LOW = "2";
const string CommonConstant::TASK_STRING_STATUS_FINISHED = "FINISHED";
const string CommonConstant::TASK_STRING_STATUS_NOT_FINISHED = "UNFINISHED";
const string CommonConstant::FLOATING_TASK_STRING_FORMAT = "_______Task[%s]_______\n%s\n%s\nPriority: %s\nStatus: %s\n----------------------";
const string CommonConstant::DEADLINE_TASK_STRING_FORMAT = "%s\nDue by %s %s\n%s";
const string CommonConstant::TIMED_TASK_STRING_FORMAT = "%s\nFrom %s %s\ntill %s %s\n%s";
const string CommonConstant::PATTERN = "----------------------";

const string CommonConstant::KEYWORD_TASK_ALL = "/all";
const string CommonConstant::KEYWORD_TASK_TITLE = "/t";
const string CommonConstant::KEYWORD_TASK_DESCRIPTION ="/de";
const string CommonConstant::KEYWORD_TASK_LOCATION = "/l";
const string CommonConstant::KEYWORD_TASK_PERSON = "/pe";
const string CommonConstant::KEYWORD_TASK_START_TIME = "/st";
const string CommonConstant::KEYWORD_TASK_END_TIME = "/et";
const string CommonConstant::KEYWORD_TASK_START_DATE = "/sd";
const string CommonConstant::KEYWORD_TASK_END_DATE = "/ed";
const string CommonConstant::KEYWORD_TASK_PRIORITY = "/pr";
const string CommonConstant::KEYWORD_TASK_DATE = "/d";
const string CommonConstant::KEYWORD_TASK_FINISHED_STATUS = "/f";
const string CommonConstant::KEYWORD_SYSTEM_START_TIME = "/sst";
const string CommonConstant::KEYWORD_SEARCH_AVAILABILITY = "/a";
const string CommonConstant::KEYWORD_SEARCH_TIME = "/st";
const string CommonConstant::KEYWORD_END_TIME = "/et";
const string CommonConstant::KEYWORD_SEARCH_DEFAULT = "/default";
const string CommonConstant::KEYWORD_SEARCH_DATE = "/sd";

const string CommonConstant::DATE_NEXT = "next";
const int CommonConstant::DATE_ADD_DAY = 1;
const int CommonConstant::DATE_ADD_HOUR = 1;
const int CommonConstant::DATE_SUBTRACT_DAY =1;

const string CommonConstant::TIME_AM = "am";
const string CommonConstant::TIME_A = "a";
const string CommonConstant::TIME_PM = "pm";
const string CommonConstant::TIME_P = "p";
const char* CommonConstant::TIME_AM_CHAR = "am";
const char* CommonConstant::TIME_PM_CHAR = "pm";

const int CommonConstant::MONTH_JAN = 1;
const int CommonConstant::MONTH_FEB = 2;
const int CommonConstant::MONTH_MAR = 3;
const int CommonConstant::MONTH_APR = 4;
const int CommonConstant::MONTH_MAY = 5;
const int CommonConstant::MONTH_JUN = 6;
const int CommonConstant::MONTH_JUL = 7;
const int CommonConstant::MONTH_AUG = 8;
const int CommonConstant::MONTH_SEP = 9;
const int CommonConstant::MONTH_OCT = 10;
const int CommonConstant::MONTH_NOV = 11;
const int CommonConstant::MONTH_DEC = 12;

const char* CommonConstant::MONTH_JAN_SHORT_CHAR = "jan";
const char* CommonConstant::MONTH_JAN_LONG_CHAR = "january";
const char* CommonConstant::MONTH_FEB_SHORT_CHAR = "feb";
const char* CommonConstant::MONTH_FEB_LONG_CHAR = "february";
const char* CommonConstant::MONTH_MAR_SHORT_CHAR = "mar";
const char* CommonConstant::MONTH_MAR_LONG_CHAR = "march";
const char* CommonConstant::MONTH_APR_SHORT_CHAR = "apr";
const char* CommonConstant::MONTH_APR_LONG_CHAR = "april";
const char* CommonConstant::MONTH_MAY_SHORT_CHAR = "may";
const char* CommonConstant::MONTH_MAY_LONG_CHAR = "may";
const char* CommonConstant::MONTH_JUN_SHORT_CHAR = "jun";
const char* CommonConstant::MONTH_JUN_LONG_CHAR = "june";
const char* CommonConstant::MONTH_JUL_SHORT_CHAR = "jul";
const char* CommonConstant::MONTH_JUL_LONG_CHAR = "july";
const char* CommonConstant::MONTH_AUG_SHORT_CHAR = "aug";
const char* CommonConstant::MONTH_AUG_LONG_CHAR = "august";
const char* CommonConstant::MONTH_SEP_SHORT_CHAR = "sep";
const char* CommonConstant::MONTH_SEP_LONG_CHAR = "september";
const char* CommonConstant::MONTH_OCT_SHORT_CHAR = "oct";
const char* CommonConstant::MONTH_OCT_LONG_CHAR = "october";
const char* CommonConstant::MONTH_NOV_SHORT_CHAR = "nov";
const char* CommonConstant::MONTH_NOV_LONG_CHAR = "november";
const char* CommonConstant::MONTH_DEC_SHORT_CHAR = "dec";
const char* CommonConstant::MONTH_DEC_LONG_CHAR = "december";

const int CommonConstant::DATE_MAX_DAY_MONTH = 31;
const int CommonConstant::DATE_MAX_DAY_WEEK = 7;
const int CommonConstant::MAX_SECONDS_DAY = 86400;
const int CommonConstant::DATE_MAX_MONTH_YEAR = 12;
const int CommonConstant::DATE_LEAP_YEAR = 4;
const int CommonConstant::DATE_LEAP_YEAR_CENTURY = 400;
const int CommonConstant::DATE_CENTURY = 100;
const int CommonConstant::DATE_FEBRUARY_LEAP_YEAR_DAYS = 29;
const int CommonConstant::DATE_DAYS_MONTH_LIMIT = 32;
const int CommonConstant::DATE_THIRTY = 30;
const int CommonConstant::SECONDS_PER_HOUR = 3600;
const int CommonConstant::AM_PM_CONVERTION = 12;
const int CommonConstant::NOON = 12;
const int CommonConstant::MAX_HOUR = 23;
const int CommonConstant::MIN_HOUR = 0;
const int CommonConstant::MAX_MINUTE = 59;
const int CommonConstant::MIN_MINUTE = 0;
const int CommonConstant::MIN_HOUR_AM = 0;
const int CommonConstant::MAX_HOUR_AM = 11;
const int CommonConstant::MIN_HOUR_PM = 1;
const int CommonConstant::MAX_HOUR_PM = 12;

